package com.gg.fmallspringboot.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gg.fmallspringboot.entity.Product;
import com.gg.fmallspringboot.entity.ProductSku;
import com.gg.fmallspringboot.mapper.ProductImgMapper;
import com.gg.fmallspringboot.mapper.ProductMapper;
import com.gg.fmallspringboot.mapper.ProductSkuMapper;
import com.gg.fmallspringboot.model.Result;
import com.gg.fmallspringboot.service.ProductService;
import com.gg.fmallspringboot.service.ProductSkuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * 作者:Miki
 * 时间:2021/6/21 12:52
 */
@Service
public class ProductSkuServiceImpl implements ProductSkuService {

    @Autowired
    private ProductSkuMapper productSkuMapper;
    @Resource
    private ProductMapper productMapper;


    @Override
    public ProductSku getOneById(String skuId) {
        QueryWrapper<ProductSku> qw = new QueryWrapper<>();
        qw.eq("sku_id", skuId);
        return productSkuMapper.selectOne(qw);
    }

    @Override
    public ProductSku getOne(String skuId) {

        QueryWrapper<ProductSku> qw = new QueryWrapper<>();
        qw.eq("sku_id",skuId);
        return (ProductSku)productSkuMapper.selectOne(qw);
    }

    @Override
    public Result queyProductById(String skuId) {
        List<ProductSku> productSkus = productSkuMapper.queryProductSkuById(skuId);
        Product product = productMapper.queryProductById(skuId);
        HashMap map = new HashMap();
        map.put("productSkus",productSkus);
        map.put("product",product);
        Result result = new Result(0,null,map);
        return result;
    }
}
